﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBUtility;

public partial class Manageweb_Control_LeftINewsForLock : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ControlDataInit();
    }


    #region ControlDataInit
    protected void ControlDataInit()
    {
        string SQLstr_INewsForLock = "SELECT * FROM [INewsClass]";
        SQLstr_INewsForLock += " WHERE [INC_IsLock]=true ORDER BY [INC_ClassCode]";

        DataTable DT_INewsForLock = AccHelper.GetDataTable(SQLstr_INewsForLock);

        InitTree(TV_INewsForLock.Nodes, "0", DT_INewsForLock);
    }
    #endregion


    #region InitTree
    private void InitTree(TreeNodeCollection tnParent, string parentId, DataTable dt)
    {
        foreach (DataRow dr in dt.Select("[INC_ParentID]='" + parentId + "'"))
        {
            TreeNode tn = new TreeNode();

            tn.Value = dr["INC_ID"].ToString();
            tn.Text = dr["INC_Title"].ToString();
            tn.Target = "mainFrame";
            tn.NavigateUrl = "~/Manageweb/ManageINews/ManageINews.aspx?ClassID=" + dr["INC_ID"].ToString();

            tnParent.Add(tn);


            TreeNode tn2 = new TreeNode();

            tn2.Value = dr["INC_ID"].ToString();
            tn2.Text = "添加" + dr["INC_Title"].ToString();
            tn2.Target = "mainFrame";
            tn2.NavigateUrl = "~/Manageweb/ManageINews/AddINews.aspx?ClassID=" + dr["INC_ID"].ToString();

            tn.ChildNodes.Add(tn2);


            TreeNode tn3 = new TreeNode();

            tn3.Value = dr["INC_ID"].ToString();
            tn3.Text = "管理" + dr["INC_Title"].ToString();
            tn3.Target = "mainFrame";
            tn3.NavigateUrl = "~/Manageweb/ManageINews/ManageINews.aspx?ClassID=" + dr["INC_ID"].ToString();

            tn.ChildNodes.Add(tn3);

            InitTree(tnParent[tnParent.Count - 1].ChildNodes, tn.Value, dt);
        }
    }
    #endregion
}
